// .txt

beginzonescript;

variables;

short crime_tolerance = 5;
short last_abil;
short i;
short cutscene = 0;
short walk_timer = 0;


body;

beginstate INIT_STATE;
	sf(12,16,0);
	sf(12,20,0);
	sf(12,21,0);
	sf(12,22,0);
	sf(12,23,0);
	
	set_name(9,"Baston");
	if (gf(12,1) > 0)
		erase_char(9);
	if (gf(11,1) > 0)
		erase_char(9);

	set_name(15,"Captain Herszen");
	set_level(15,28);
	set_new_abil(15,20);
	set_boss_level(15,1);
	set_name(16,"Sage Quothe");
	set_aggression(16,8);
	set_boss_level(16,1);
	set_name(20,"Masha");
	set_name(21,"Sergeant Flesch");
	if (gf(12,11) > 1)
		erase_char(21);

	set_name(22,"Farseeing Shaper");
	set_name(26,"Farseeing Shaper");
	set_name(30,"Farseeing Shaper");
	set_name(31,"Farseeing Shaper");
	set_name(32,"Farseeing Shaper");
	set_name(33,"Farseeing Shaper");

	add_range_to_group(46,50,2);
	add_range_to_group(51,55,3);
	add_range_to_group(59,60,4);
	set_aggression(1002,9);
	set_aggression(1003,9);
	set_aggression(1004,9);
	
	if (gf(100,11) > 0) {
		print_str_color("Word of your infamy has gotten here before you. You are forever marked",3);
		print_str_color("  as a foe of the Shapers.",3);
		sf(11,1,1);
		}
	if (get_sdf(11,1) > 0) {
		make_zone_hostile();
		}
		else {
			print_str_color("This is a friendly city. You are able to rest.",2);
			revive_party();
			}	

	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((gf(11,1) > 0) && (gf(100,2) == 2)) {
		sf(100,2,3);
		print_str_color("Now that Haria-Kel is angry with you, you will no longer be",3);
		print_str_color("  able to serve Astoria.",3);
		}

	// clear zone?
	//if ((zone_clear(ME) == FALSE) && (get_flag(,) > 0)) {
		//print_str_color("",2);
		//clear_zone(ME);	
		//}
		
	if ((get_crime_level() >= crime_tolerance) && (get_sdf(11,1) == 0)) {
		make_zone_hostile();
		set_flag(11,1,1);
		}

	 if (gf(11,1) == 0) {
		if ((gf(12,1) > 0) && (gf(12,2) < 6) && (gf(12,1) > 1)) {		
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(8,"It won't be tolerated.");
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(8,"You will aid me.");
			if (get_ran(1,0,100) < 10)
				give_char_text_bubble(8,"They must be caught.");
			}
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"You are fascinating.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"What an odd creature.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"How can we beat them?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(16,"Curse the Unbound!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(20,"A new face?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(20,"I will never escape.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(20,"Let us talk.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Watching.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Contacting.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Go west.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Go north.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Go south.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Go east.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Pause.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Investigate.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(30 + get_ran(1,0,3),"Withdraw.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15,"Who is doing it?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15,"So many foes.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15,"Must watch the road.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(15,"You are welcome.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(21,"Why didn't I tie it better?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(21,"Stupid ornk!");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(21,"I am in such trouble.");

		}
	
	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 3))) {
		last_abil = get_current_tick();

		walk_timer = walk_timer + 1;
		if (walk_timer >= 4) {
			walk_timer = 0;
			if (gf(12,13) == 0)
				sf(12,13,1);
				else sf(12,13,0);
			}
		

		}
	
	if (gf(12,1) == 1) {
		if (cutscene == 1) {
			cutscene = 2;
			give_char_text_bubble(9,"Bah!");
			give_char_text_bubble(8,"Approach, Rawal's creature.");

			begin_talk_mode(30);
			}
		else if (cutscene == 2) {
			move_to_loc(9,60,16);
			
			move_to_loc(0,54,16);
			move_to_loc(1,53,17);
			move_to_loc(2,55,17);
			move_to_loc(3,54,18);
			move_to_loc(4,52,18);
			move_to_loc(5,56,18);
			move_to_loc(6,53,19);
			move_to_loc(7,55,19);
			shift_view_to_char(pc_num());
			
			
			if ((cutscene_can_proceed()) && (party_near_nav(1,4))) {
				give_char_text_bubble(8,"");
				give_char_text_bubble(9,"");
				set_facing(1000,7);
				set_facing(9,1);
				shift_view_to_char(pc_num());
				cutscene = 3;
				}
			}
		else if (cutscene == 3) {
			cutscene = 6;
			}
		else if (cutscene == 6) {
			cutscene = 8;
			begin_talk_mode(32);
			}
		else if (cutscene == 8) {
			give_char_text_bubble(9,"Enough!");
			cutscene = 9;
			}
		else if (cutscene == 9) {
			move_to_loc(9,57,15);
			if (cutscene_can_proceed()) {
				cutscene = 10;
				}
			}
		else if (cutscene == 10) {
			cutscene = 11;
			}
		else if (cutscene == 11) {
			cutscene = 14;
			begin_talk_mode(36);
			}
		else if (cutscene == 14) {
			spawn_creature(2);
			spawn_creature(3);
			spawn_creature(4);
			spawn_creature(5);
			place_particle_num(10,10,7,10);
			place_particle_num(11,10,7,10);
			place_particle_num(12,10,7,10);
			place_particle_num(13,10,7,10);
			set_strategy(9,12);
			set_strategy(12,12);
			set_strategy(13,12);
			set_boss_level(10,1);
			set_boss_level(11,1);
			set_boss_level(12,1);
			set_boss_level(13,1);
			
			cutscene = 15;
			}
		else if (cutscene == 15) {
			cutscene = 16;
			sf(12,1,2);
			
			set_attitude(9,10);
			set_attitude(10,10);
			set_attitude(11,10);
			set_attitude(12,10);
			set_attitude(13,10);
			set_foe_target(9,8);
			set_foe_target(10,8);
			set_foe_target(11,8);
			set_foe_target(12,8);
			set_foe_target(13,8);

			add_range_to_group(9,13,1);
			
			toggle_cutscene(0);
			shift_view_to_char(pc_num());
			begin_talk_mode(38);
			}
		
		}
break;


beginstate 10;
	if ((gf(12,1) == 0) && (gf(11,1) == 0) && (char_ok(8))) {
		cutscene = 1;
		sf(12,1,1);
		char_clear_action(1000);
		toggle_cutscene(1);
		}
break;

beginstate 11;
	sf(12,4,1);
break;

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
